/*
 * Copyright 2013 Agustina Martinez-Garcia

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package uk.da.dext.datastructs;

import java.util.ArrayList;
import java.util.List;

public class CodeStruct {
    	/**
	 * Code Assigned Fedora Pid
	 */
	private String codePid;
	private String codeAuthority;
	private String codeXmlId;
	private String codeLabel;
	private String codeDisplayLabel;
	private String codeLanguage;
	/**
	 * Holds a list of the associated document references with a given category
	 * In this case each document reference will be the row number of the referenced document
	 * Shouldn't it has to be the document generated XML IDs?????
	 */
	private List<String> documentRefs;
	/**
	 * Documents XML IDs, not the Fedora PIDs, this is needed when generating the Qudex instances
	 */
	private List<String> documentRefsXmlIds;
	/**
	 * @param codeAuthority the codeAuthority to set
	 */
	public void setCodeAuthority(String codeAuthority) {
		this.codeAuthority = codeAuthority;
	}
	/**
	 * @return the codeAuthority
	 */
	public String getCodeAuthority() {
		return codeAuthority;
	}
	/**
	 * @param codeXmlId the codeXmlId to set
	 */
	public void setCodeXmlId(String codeXmlId) {
		this.codeXmlId = codeXmlId;
	}
	/**
	 * @return the codeXmlId
	 */
	public String getCodeXmlId() {
		return codeXmlId;
	}
	/**
	 * @param codeLabel the codeLabel to set
	 */
	public void setCodeLabel(String codeLabel) {
		this.codeLabel = codeLabel;
	}
	/**
	 * @return the codeLabel
	 */
	public String getCodeLabel() {
		return codeLabel;
	}
	/**
	 * @param codeDisplayLabel the codeDisplayLabel to set
	 */
	public void setCodeDisplayLabel(String codeDisplayLabel) {
		this.codeDisplayLabel = codeDisplayLabel;
	}
	/**
	 * @return the codeDisplayLabel
	 */
	public String getCodeDisplayLabel() {
		return codeDisplayLabel;
	}
	/**
	 * @param documentRefs the documentRefs to set
	 */
	public void setDocumentRefs(List<String> documentRefs) {
		this.documentRefs = documentRefs;
	}
	/**
	 * @return the documentRefs
	 */
	public List<String> getDocumentRefs() {
		return documentRefs;
	}
	/**
	 * @param documentRefsXmlIds the documentRefsXmlIds to set
	 */
	public void setDocumentRefsXmlIds(List<String> documentRefsXmlIds) {
		this.documentRefsXmlIds = documentRefsXmlIds;
	}
	/**
	 * @return the documentRefsXmlIds
	 */
	public List<String> getDocumentRefsXmlIds() {
		return documentRefsXmlIds;
	}
	
	public CodeStruct(String label) {
		this.codeLabel = label;
		this.documentRefs = new ArrayList<String>();
		this.documentRefsXmlIds = new ArrayList<String>();
		this.codeXmlId = "";
		this.codeDisplayLabel = "";
		this.codeLanguage = "";
	}
	
	public CodeStruct() {
		this.codeLabel = "";
		this.documentRefs = new ArrayList<String>();
		this.documentRefsXmlIds = new ArrayList<String>();
		this.codeXmlId = "";
		this.codeDisplayLabel = "";
		this.codeLanguage = "";
	}
	/**
	 * Clears all the elements from the lists managed by the code object:
	 * list of parents, list of children and list of document references
	 */
	public void clearCodeLists() {
		this.documentRefs.clear();
		this.documentRefsXmlIds.clear();
	}
	/**
	 * @param codeLanguage the codeLanguage to set
	 */
	public void setCodeLanguage(String codeLanguage) {
		this.codeLanguage = codeLanguage;
	}
	/**
	 * @return the codeLanguage
	 */
	public String getCodeLanguage() {
		return codeLanguage;
	}
	/**
	 * Finds a document reference within the list of document references of a particular code
	 * @param docRef name of the document reference to find
	 * @return true if element present
	 */
	public boolean findDocumentRef(String docRef) {
		return this.documentRefs.contains(docRef);
	}
	/**
	 * @param codePid the codePid to set
	 */
	public void setCodePid(String codePid) {
	    this.codePid = codePid;
	}
	/**
	 * @return the codePid
	 */
	public String getCodePid() {
	    return codePid;
	}
}
